<?php

declare(strict_types=1);

use Dotenv\Repository\RepositoryBuilder;
use Dotenv\Repository\Adapter;

error_reporting(E_ALL);
date_default_timezone_set('Asia/Shanghai');

! defined('BASE_PATH') && define('BASE_PATH', dirname(__DIR__, 1));
! defined('SWOOLE_HOOK_FLAGS') && define('SWOOLE_HOOK_FLAGS', SWOOLE_HOOK_ALL);

Swoole\Runtime::enableCoroutine(true);

require BASE_PATH . '/vendor/autoload.php';
// Load env before config.
if (file_exists(BASE_PATH . '/.env.test')) {
    $repository = RepositoryBuilder::create()
        ->withReaders([
            new Adapter\PutenvAdapter(),
        ])
        ->withWriters([
            new Adapter\PutenvAdapter(),
        ])
        ->immutable()
        ->make();

    \Dotenv\Dotenv::create($repository, [BASE_PATH], '.env.test')->load();
}

Hyperf\Di\ClassLoader::init();

$container = require BASE_PATH . '/config/container.php';

$container->get(Hyperf\Contract\ApplicationInterface::class);
